<?php
session_start();
//if(isset($_REQUEST['btn_submit']) && $_REQUEST['btn_submit'] == 'Submit')
include("connect.php");
if(!isset($_SESSION['savedres']) || $_SESSION['savedres']=='')
{
	$val=$_POST['arrRecord'];
	$date=$_SESSION['testtime'];
	$values=explode(',',$val);
	//$testtime=$_SESSION['testtime'];
	foreach($values as $value)
	{
		$f_val=explode('$',$value);
		$id=$f_val[0];
		$queslevel=mysql_query("SELECT * FROM questionbank WHERE question_id=$id");
		$quesres=mysql_fetch_object($queslevel);
		$atmpt=(!isset($f_val[1]) || $f_val[1]=='')? '0' : $f_val[1];
		$sql="insert into question_set(question_id,question_level,user_id,correct_ans,attempt_ans,marks,question_set_group,testTime) values($id,$quesres->level_id,$_SESSION[user_id],$quesres->ans,$atmpt,1,'$_SESSION[ques_group]','$date')";
		mysql_query($sql);
	/*
		if(mysql_affected_rows()>0)
			echo "Added Succesfully";
		else
			echo "ERROR";
	*/
	}
	$_SESSION['savedres']='saved';
}
?>
